// -----------------------------
// Author: 		Dhaenens Gert 
// Creation: 	10/18/2014 1:21:49 AM				
// -----------------------------

#ifndef _TerrainMaterial_h
#define _TerrainMaterial_h

#include "Material.h"

class TerrainMaterial : public Material
{
public:

	Color	m_Diffuse;
	Color	m_Ambient;
	Float	m_Roughness;
	Float	m_Specular;
	Float	m_MinimumHeight;
	Float	m_MaximumHeight;
	Float	m_MinimumDistance;
	Float	m_MaximumDistance;
	Float	m_MaximumTessFactor;
	Float	m_TerrainWidth;
	Float	m_TerrainHeight;

	TerrainMaterial(Application* lpApp);

	virtual void	Apply(Application* lpApp);
	virtual void	UpdateMatrices(Application* lpApp);
	virtual void	UpdateData(Application* lpApp);

	virtual void	SetDiffuseTexture(const RefPtr<ITexture2D>& lpTexture);
	virtual void	SetHeightTexture(const RefPtr<ITexture2D>& lpTexture);

	virtual Bool	SampleGeometryOutput(const Vector3& pin, Vector3& pout, Vector3& nout) const;

private:

	virtual ~TerrainMaterial();

	void			Init(Application* lpApp);

	IVertexShader*		m_lpVertexShader;

	IHullShader*		m_lpHullShader;
	IBuffer*			m_lpTessInfoBuffer;

	IDomainShader*		m_lpDomainShader;

	IGeometryShader*	m_lpGeometryShader;
	IBuffer*			m_lpMatrixBuffer;
	IBuffer*			m_lpTerrainBuffer;
	IBuffer*			m_lpGeometryOutput;

	IPixelShader*		m_lpPixelShader;
	IBuffer*			m_lpMaterialBuffer;

	RefPtr<ITexture2D>	m_lpDiffuseTexture;
	RefPtr<ITexture2D>	m_lpHeightTexture;

	IInputLayout*	m_lpInputLayout;
	ISamplerState*	m_lpSamplerState;

	TerrainMaterial(const TerrainMaterial& refTerrainMaterial);
	TerrainMaterial& operator=(const TerrainMaterial& refTerrainMaterial);
};

#endif